package com.dhcc.DRGsHosp.facade.impl.assembler;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.dhcc.DRGsHosp.core.domain.DictionaryData;
import com.dhcc.DRGsHosp.facade.dto.DictionaryDataDTO;

public class DictionaryDataAssembler {
	
	public static DictionaryDataDTO  toDTO(DictionaryData  dictionaryData){
		if (dictionaryData == null) {
			return null;
		}
    	DictionaryDataDTO result  = new DictionaryDataDTO();
	    	result.setDicCode(dictionaryData.getPkId().getDIC_CODE());
	    	result.setDicValue(dictionaryData.getPkId().getDIC_VALUE());
	    	result.setDicResume(dictionaryData.getDicResume());
     	    result.setDicDesc(dictionaryData.getDicDesc());
     	    return result;
	 }
	
	public static List<DictionaryDataDTO>  toDTOs(Collection<DictionaryData>  dictionaryDatas){
		if (dictionaryDatas == null) {
			return null;
		}
		List<DictionaryDataDTO> results = new ArrayList<DictionaryDataDTO>();
		for (DictionaryData each : dictionaryDatas) {
			results.add(toDTO(each));
		}
		return results;
	}
	
	 public static DictionaryData  toEntity(DictionaryDataDTO  dictionaryDataDTO){
	 	if (dictionaryDataDTO == null) {
			return null;
		}
	 	DictionaryData result  = new DictionaryData();
	    result.getPkId().setDIC_VALUE(dictionaryDataDTO.getDicValue());
	    result.setDicResume(dictionaryDataDTO.getDicResume());
  	    result.getPkId().setDIC_CODE(dictionaryDataDTO.getDicCode());
  	    result.setDicDesc(dictionaryDataDTO.getDicDesc());
 	  	return result;
	 }
	
	public static List<DictionaryData> toEntities(Collection<DictionaryDataDTO> dictionaryDataDTOs) {
		if (dictionaryDataDTOs == null) {
			return null;
		}
		
		List<DictionaryData> results = new ArrayList<DictionaryData>();
		for (DictionaryDataDTO each : dictionaryDataDTOs) {
			results.add(toEntity(each));
		}
		return results;
	}
}
